#!/usr/bin/env python3
"""
Run tests for the Event Contract Platform
"""

import subprocess
import sys
import os

def run_tests():
    """Run all tests"""
    print("Running Event Contract Platform Tests...")
    print("=" * 50)
    
    # Change to project directory
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    
    try:
        # Run pytest
        result = subprocess.run([
            sys.executable, "-m", "pytest", 
            "tests/", 
            "-v", 
            "--tb=short"
        ], check=True)
        
        print("\n" + "=" * 50)
        print("✅ All tests passed!")
        return True
        
    except subprocess.CalledProcessError as e:
        print("\n" + "=" * 50)
        print("❌ Some tests failed!")
        print(f"Exit code: {e.returncode}")
        return False
    except FileNotFoundError:
        print("❌ pytest not found. Please install dependencies first:")
        print("pip install -r requirements.txt")
        return False

if __name__ == "__main__":
    success = run_tests()
    sys.exit(0 if success else 1)
